<?

/**
* We filter any NULL entry
* of passedJobId
*
*/
$Misc->filterOutNull($_SESSION["passedJobId"]);

/**
* We extract the passed string and jobId
*
*/
if($_SESSION["modify_mode"] == "Y"){


}else{


}

if($COracle->connect()){

  $CLFetchers->fetchLstWarehouse($COracle,
                                 $srcDbWarehouse,
                                 $lstWarehouse);

  echo  "<table border='1' class='dedeq'>\n".
        "<th> NO      </th>\n".
        "<th> Drop    </th>\n".
        "<th> Model   </th>\n".
        "<th> Cvt     </th>\n".
        "<th> Cvt-Qty </th>\n".
        "<th> Unit    </th>\n".
        "<th> Qty     </th>\n".
        "<th> WHS     </th>\n".
        "<th> SER-NUM </th>\n".
        "<th> Price   </th>\n".
        "<th> #       </th>\n".
        "<th> DISC%   </th>\n".
        "<th> DISC    </th>\n".
        "<th> NET     </th>\n";

  for($iRow = 0; $iRow < $_SESSION["init_num"]; $iRow++){

    /**
    *------------------------------------------------------------------------------
    * All property goes here
    *
    */
    $propHrzTot    = $CJs->jsOnFocus("GMisc.setYellow2(this);
                                      GMisc.syncVal2(\"hrzTotEnt[".$iRow."]\",
                                                     \"totHrzTotEnt\");
                                      Misc.hrzTot(\"qtyEnt[".$iRow."]\",
                                                  \"priceEnt[".$iRow."]\",
                                                  this);").

                     $CJs->jsOnBlur ("GMisc.sumVal2(\"hrzTotEnt[".$iRow."]\",
                                                    \"totHrzTotEnt\");
                                      GMisc.setWhite2(this);");

    $propSerNumber = $CJs->jsOnFocus("setYellow2(this);").

                     $CJs->jsOnBlur ("setSerNumber4(\"serNumStartEnt[".$iRow."]\",
                                                    \"serNumLengthEnt[".$iRow."]\",
                                                    \"recvQtyEnt[".$iRow."]\",
                                                    \"serNumEnt[".$iRow."]\");
                                      setWhite2(this);");

    $propDiscPctg  = $CJs->jsOnFocus("setYellow2(this);
                                      syncVal2F(\"discEnt[".$iRow."]\",
                                                \"totDiscEnt\");").

                     $CJs->jsOnBlur ("setDiscount(\"hrzTotEnt[".$iRow."]\",
                                                  \"discPctgEnt[".$iRow."]\",
                                                  \"discEnt[".$iRow."]\");
                                      sumVal2F(\"discEnt[".$iRow."]\",
                                               \"totDiscEnt\");
                                      setWhite2(this);");

    $propDiscount  = $CJs->jsOnFocus("setYellow2(this);
                                      syncVal2F(\"netEnt[".$iRow."]\",
                                                \"totNetEnt\");
                                      syncVal2F(\"discEnt[".$iRow."]\",
                                                \"totDiscEnt\");").

                     $CJs->jsOnBlur ("setNetto(\"hrzTotEnt[".$iRow."]\",
                                               \"discEnt[".$iRow."]\",
                                               \"netEnt[".$iRow."]\");
                                      sumVal2F(\"netEnt[".$iRow."]\",
                                                \"totNetEnt\");
                                      sumVal2F(\"discEnt[".$iRow."]\",
                                               \"totDiscEnt\");
                                      setWhite2(this);");

    $propNetto     = $CJs->jsOnFocus("setYellow2(this);
                                      syncVal2F(\"totNetEnt[".$iRow."]\",
                                                \"amountEnt\");
                                      syncVal2F(\"netEnt[".$iRow."]\",
                                                \"totNetEnt[".$iRow."]\");").

                     $CJs->jsOnBlur ("sumVal2F(\"netEnt[".$iRow."]\",
                                                \"totNetEnt[".$iRow."]\");
                                      sumVal2F(\"totNetEnt[".$iRow."]\",
                                               \"amountEnt\");
                                      setWhite2(this);");

    $propModel     = $CJs->jsOnFocus("GMisc.setYellow2(this);
                                      Ajax.model(1,
                                                 this);").

                     $CJs->jsOnBlur ("GMisc.setWhite2(this);");

    $propUnit      = $CJs->jsOnFocus("GMisc.setYellow2(this);
                                      Ajax.unit(\"modelEnt[".$iRow."]\",
                                                1, /* 1 is From, 0 is To */
                                                this);").

                     $CJs->jsOnBlur ("GMisc.setWhite2(this);");

    $propCvt       = $CJs->jsOnFocus("GMisc.setYellow2(this);
                                      Ajax.unit(\"modelEnt[".$iRow."]\",
                                                0, /* 1 is From, 0 is To */
                                                this);").

                     $CJs->jsOnBlur ("GMisc.setWhite2(this);");

    $propCvtQty    = $CJs->jsOnFocus("GMisc.setYellow2(this);
                                      Ajax.cvtQty(\"modelEnt[".$iRow."]\",
                                                  \"cvtEnt[".$iRow."]\",
                                                  \"cvtQtyEnt[".$iRow."]\",
                                                  \"unitEnt[".$iRow."]\",
                                                  this);").

                     $CJs->jsOnBlur ("GMisc.setWhite2(this);");

    $propDrop      = $CJs->jsOnChange("Misc.procDrop(this,
                                                     \"prevStatus[".$iRow."]\",
                                                     \"hrzTotEnt[".$iRow."]\",
                                                     \"totHrzTotEnt\",
                                                     \"discEnt[".$iRow."]\",
                                                     \"totDiscEnt\",
                                                     \"netEnt[".$iRow."]\",
                                                     \"totNetEnt\");");

    $lstModel = $Misc->retArray($_POST["modelEnt"][$iRow]);

    $lstUnit  = $Misc->retArray($_POST["unitEnt"][$iRow]);

    $lstCvt   = $Misc->retArray($_POST["cvtEnt"][$iRow]);

    if($_POST["discPctgEnt"][$iRow] == ""){

      $_POST["discPctgEnt"][$iRow] = 0;
    }

    if($_POST["discEnt"][$iRow] == ""){

      $_POST["discEnt"][$iRow] = 0;
    }

    if($_POST["netEnt"][$iRow] == ""){

      $_POST["netEnt"][$iRow] = 0;
    }

    if(1){

      /**
       * deprecated
       * " <td> ".$CHtml->formInput("serNumEnt[".$iRow."]",
                                                 $_POST["serNumEnt"][$iRow],
                                                 $propSerNumber.
                                                 $numStyle.
                                                 $serNumModel)." </td>

           <td> ".$CHtml->actionIcon("miniInput",
                                    "miniInput[".$iRow."]",
                                    15,
                                    15,
                                    "/ecs/images/modify.png",
                                    "miniInput(\"".$_SERVER["HTTP_HOST"]."\",
                                               \"miniInput[".$iRow."]\",
                                               \"serNumEnt[".$iRow."]\",
                                               \"recvRefEnt[".$iRow."]\",
                                               \"recvQtyEnt[".$iRow."]\",
                                               \"".$iJid."\")")." </td>*/

       $addSerNumber = " <td> ".$CHtml->actionIcon("miniView",
                                                   "miniView[".$iRow."]",
                                                   15,
                                                   15,
                                                   "/ecs/images/view.png",
                                                   "Misc.miniView(\"".$_SERVER["HTTP_HOST"]."\",
                                                                  \"modelEnt[".$iRow."]\",
                                                                  \"notaSrcEnt\");")." </td> ";

      /**
      * These routines should be add in serNum input field
      * but temporary removed
      */
    }else{

      $addSerNumber = " <td> ".$CHtml->formHidden("serNumEnt[".$iRow."]",
                                                  $_POST["serNumEnt"][$iRow],
                                                  _NO_PROPERTY)." </td> ";
    }

    echo  "<tr>\n".

            "<td> ".($iRow+1)." </td>\n".

            "<td> ".$CHtml->formCheckBox("dropBox[]",
                                         ($iRow+1),
                                         $propDrop)."

                  ".$CHtml->formHidden("prevStatus[".$iRow."]",
                                       $_POST["prevStatus"][$iRow])."  </td>\n".

            "<td> ".$CHtml->formDropDown("modelEnt[".$iRow."]",
                                         $_POST["modelEnt"][$iRow],
                                         $lstModel,
                                         $propModel)." </td>\n".

            "<td> ".$CHtml->formDropDown("cvtEnt[".$iRow."]",
                                         $_POST["cvtEnt"][$iRow],
                                         $lstCvt,
                                         $propCvt)." </td>\n".

            "<td> ".$CHtml->formInput("cvtQtyEnt[".$iRow."]",
                                      $_POST["cvtQtyEnt"][$iRow],
                                      $Misc->stdProperties().
                                      $Misc->stdNumStyle(5))." </td>\n".

            "<td> ".$CHtml->formDropDown("unitEnt[".$iRow."]",
                                         $_POST["unitEnt"][$iRow],
                                         $lstUnit,
                                         $propUnit)." </td>\n".

            "<td> ".$CHtml->formInput("qtyEnt[".$iRow."]",
                                      $_POST["qtyEnt"][$iRow],
                                      $propCvtQty.
                                      $Misc->stdNumStyle(5))." </td>\n".

            "<td> ".$CHtml->formDropDown("whsEnt[".$iRow."]",
                                         $_POST["whsEnt"][$iRow],
                                         $lstWarehouse,
                                         $Misc->stdProperties())." </td>\n".

            "<td>   <table class='dedeq'>
                    <tr>

                    ".$addSerNumber."

                    <tr>
                    </table>
                  </td>\n".

            "<td> ".$CHtml->formInput("priceEnt[".$iRow."]",
                                      $_POST["priceEnt"][$iRow],
                                      $Misc->stdNumStyle(5).
                                      $Misc->stdProperties())." </td>\n".

            "<td> ".$CHtml->formInput("hrzTotEnt[".$iRow."]",
                                      $_POST["hrzTotEnt"][$iRow],
                                      $Misc->stdNumStyle(5).
                                      $propHrzTot)." </td>\n".

            "<td> ".$CHtml->formInput("discPctgEnt[".$iRow."]",
                                      $_POST["discPctgEnt"][$iRow],
                                      $Misc->stdNumStyle(5).
                                      $propDiscPctg)." </td>\n".

            "<td> ".$CHtml->formInput("discEnt[".$iRow."]",
                                      $_POST["discEnt"][$iRow],
                                      $Misc->stdNumStyle(5).
                                      $propDiscount)." </td>\n".

            "<td> ".$CHtml->formInput("netEnt[".$iRow."]",
                                      $_POST["netEnt"][$iRow],
                                      $Misc->stdNumStyle(16).
                                      $Misc->stdKeyProp("netEnt[".($iRow+1)."]").
                                      $Misc->stdProperties())." </td>\n".
          "</tr>\n";
  }

  /**
  * Print totals
  *
  */
  $propGDiscPctg = $CJs->jsOnFocus("GMisc.setYellow2(this);").

                   $CJs->jsOnBlur ("setDiscount(\"totNetEnt\",
                                                \"gDiscPctg\",
                                                \"totGDisc\");
                                    GMisc.setWhite2(this);");

  $propGDisc     = $CJs->jsOnFocus("GMisc.setYellow2(this);
                                    setNetto(\"totNetEnt\",
                                             \"totGDisc\",
                                             \"totAmount\");").

                   $CJs->jsOnBlur ("GMisc.setWhite2(this);");

  $propTaxPctg   = $CJs->jsOnFocus("GMisc.setYellow2(this);").

                   $CJs->jsOnBlur ("Misc.setXPctg(\"totAmount\",
                                                  \"totTaxPctg\",
                                                  \"totTax\");
                                    GMisc.setWhite2(this);");

  $propPayable   = $CJs->jsOnFocus("GMisc.setYellow2(this);
                                    Misc.setPayable(\"totAmount\",
                                                    \"totTax\",
                                                    \"totExpense\",
                                                    \"totPrepaid\",
                                                    \"totPayable\");").

                   $CJs->jsOnBlur ("GMisc.setWhite2(this);");

  $_POST["totQtyEnt"] = ($_POST["totQtyEnt"] != "")?
                         $_POST["totQtyEnt"]:
                         0;

  $_POST["totCvtQtyEnt"] = ($_POST["totCvtQtyEnt"] != "")?
                            $_POST["totCvtQtyEnt"]:
                            0;

  $_POST["totHrzTotEnt"] = ($_POST["totHrzTotEnt"] != "")?
                            $_POST["totHrzTotEnt"]:
                            0;

  $_POST["totDiscEnt"] = ($_POST["totDiscEnt"] != "")?
                          $_POST["totDiscEnt"]:
                          0;

  $_POST["totNetEnt"] = ($_POST["totNetEnt"] != "")?
                         $_POST["totNetEnt"]:
                         0;

  $_POST["gDiscPctg"] = ($_POST["gDiscPctg"] != "")?
                         $_POST["gDiscPctg"]:
                         0;

  $_POST["totGDisc"] = ($_POST["totGDisc"] != "")?
                        $_POST["totGDisc"]:
                        0;

  $_POST["totAmount"] = ($_POST["totAmount"] != "")?
                         $_POST["totAmount"]:
                         0;

  $_POST["totTaxPctg"] = ($_POST["totTaxPctg"] != "")?
                          $_POST["totTaxPctg"]:
                          0;

  $_POST["totTax"] = ($_POST["totTax"] != "")?
                      $_POST["totTax"]:
                      0;

  $_POST["totExpense"] = ($_POST["totExpense"] != "")?
                          $_POST["totExpense"]:
                          0;

  $_POST["totPrepaid"] = ($_POST["totPrepaid"] != "")?
                          $_POST["totPrepaid"]:
                          0;

  $_POST["totPayable"] = ($_POST["totPayable"] != "")?
                          $_POST["totPayable"]:
                          0;

  echo  "<tr>\n".

          "<td colspan='5'><b> TOTAL </b></td>\n".

          "<td> ".$CHtml->formHidden("totCvtQtyEnt",
                                     $_POST["totCvtQtyEnt"],
                                     $Misc->stdNumStyle(5))." </td>\n".

          "<td>  </td>\n".

          "<td> ".$CHtml->formHidden("totQtyEnt",
                                     $_POST["totQtyEnt"],
                                     $Misc->stdNumStyle(5))." </td>\n".

          "<td colspan='2'> </td>\n". //blank

          "<td> ".$CHtml->formInput("totHrzTotEnt",
                                    $_POST["totHrzTotEnt"],
                                    $Misc->stdNumStyle(5))." </td>\n".

          "<td> </td>\n". //blank

          "<td> ".$CHtml->formInput("totDiscEnt",
                                    $_POST["totDiscEnt"],
                                    $Misc->stdNumStyle(5))."</td>\n".

          "<td> ".$CHtml->formInput("totNetEnt",
                                    $_POST["totNetEnt"],
                                    $Misc->stdNumStyle(16))."</td>\n".

        "</tr>\n";

  echo  "<tr>\n".

          "<td align='right' ".$CHtml->rowColSpan( 1,11)."><b>Disc% </b></td>\n".

          "<td> ".$CHtml->formInput("gDiscPctg",
                                    $_POST["gDiscPctg"],
                                    $Misc->stdNumStyle(5).
                                    $propGDiscPctg)." </td>\n".

          "<td><b>Disc  </b></td>\n".

          "<td> ".$CHtml->formInput("totGDisc",
                                    $_POST["totGDisc"],
                                    $Misc->stdNumStyle(16).
                                    $propGDisc)." </td>\n".

        "</tr>\n".
        "<tr>\n".

          "<td align='right' ".$CHtml->rowColSpan( 1, 13)."><b>Amount  </b></td>\n".

          "<td> ".$CHtml->formInput("totAmount",
                                    $_POST["totAmount"],
                                    $Misc->stdNumStyle(16).
                                    $Misc->stdProperties())." </td>\n".

        "</tr>\n".
        "<tr>\n".

          "<td align='right' ".$CHtml->rowColSpan( 1,11)."><b>Tax%  </b></td>\n".

          "<td> ".$CHtml->formInput("totTaxPctg",
                                    $_POST["totTaxPctg"],
                                    $Misc->stdNumStyle(5).
                                    $propTaxPctg)." </td>\n".

          "<td><b>Tax   </b></td>\n".

          "<td> ".$CHtml->formInput("totTax",
                                    $_POST["totTax"],
                                    $Misc->stdNumStyle(16).
                                    $Misc->stdProperties())." </td>\n".

        "</tr>\n".
        "<tr>\n".

          "<td align='right' ".$CHtml->rowColSpan( 1, 13)."><b>Expense  </b></td>\n".

          "<td> ".$CHtml->formInput("totExpense",
                                    $_POST["totExpense"],
                                    $Misc->stdNumStyle(16).
                                    $Misc->stdProperties())." </td>\n".

        "</tr>\n".
        "<tr>\n".

          "<td align='right' ".$CHtml->rowColSpan( 1, 12)."><b>Prepaid  </b></td>\n".

          "<td name='txButton'>  </td>\n".

          "<td> ".$CHtml->formInput("totPrepaid",
                                    $_POST["totPrepaid"],
                                    $Misc->stdNumStyle(16).
                                    $Misc->stdProperties())." </td>\n".

        "</tr>\n".
        "<tr>\n".

          "<td align='right' ".$CHtml->rowColSpan( 1, 13)."><b>Payable  </b></td>\n".

          "<td> ".$CHtml->formInput("totPayable",
                                    $_POST["totPayable"],
                                    $Misc->stdNumStyle(16).
                                    $propPayable)." </td>\n".

        "</tr>\n";

  echo  $CJs->jsScript("","Ajax.setButton(\"txEnt\",
                                          \"txButton\");");

  echo  "</table>\n".
        "</br>\n";

  $COracle->dc();
}else{

  $Misc->usrDie("Oracle Connection Failed");
}

echo  $CHtml->formInputButton( "Entry-data",
                               "entry",
                               "Entry-data",
                               $stlButton).
			$CHtml->formInputButton( "Add-row",
                               "addrow",
                               "Add-row",
                               $stlButton).
      $CHtml->formInputButton( "Drop-row",
                               "droprow",
                               "Drop-row",
                               $stlButton).
    	"</form>\n ";

?>